// 登录操作
if(getCookie('uname') === '' ){
    $('.top-r_login').click(function(){
        window.location.href = '../pages/login.html'
    })
}

var myname = getCookie('uname')
if( $('.top-r_login_lg').text() !== myname ){
$('.top-r_login_lg').text(`${myname}`)
$('.login_out').css('display','block')
 if( myname === ''){
    $('.top-r_login_lg').text('登录')
    $('.login_out').css('display','none') 
 }
}
$('.login_out').click(function(){
    $('.top-r_login_lg').text('登录')
    $('.login_out').css('display','none') 
    window.location.href = '../pages/index.html'
    setCookie('uname',1,-1)
})






// 全国城市信息
// function jsonp67
getCity()
function getCity(){
$.ajax({
    url: 'https://api-gw.damai.cn/cityList.html',
    dataType: 'jsonp',
    success: function (res) {
    let str = ``
    let str1 = ``
    
    res.hotCities.forEach(item => {
        str += `
        <span class= "city-name">
        ${item}
        </span>
        `
       
    });
    res.allCities.forEach(item => {
        str1 += `
        <span class= "city-name">
        ${item}
        </span>
        `
       
    });
    $('.city-hot-cont').html(str)
    $('.city-qbcs-cont').html(str1)
    }
  })
}
// 点击切换城市 和显现
$('.city').on({
    mouseout:function(){
     
      $('.city-header').show() 
    },
   mouseleave:function(){
    $('.city-header').finish().hide() 
   } 
})
$('.city-all').on('click','.city-name',function(){
    $('.city-select').text($(this).text())
   $('.qg').text($(this).text())
})
// 点击搜索改变边框
var searchBtn = document.querySelector('.search_btn')
searchBtn.onfocus = function (){
  searchBtn.style.borderColor = '#ff1268'
}
searchBtn.onblur = function(){
    searchBtn.style.borderColor = '#f8f8f8'
}
//
$('.top-r_login').on({
    mouseout:function(){  
      $('.top-r_select').show() 
    },
   mouseleave:function(){
    $('.top-r_select').finish().hide() 
   } 
})

// 主体渲染
var arr = [
    {"name":"演唱会","id":"1"},
    {"name":"话剧歌剧","id":"3"},
    {"name":"体育比赛","id":"6","link":"https://p.damai.cn/wow/pc/act/sports"},
    {"name":"儿童亲子","id":"100"}
]
function jsonp102(res){
    var str = ``
     str += ` 
   <div class="content-head contet-head${arr[0].id}">
       <span class="content-head-tit ">${arr[0].name}</span>
       <a href="./list.html">
           <span class="content-more">查看全部</span>
       </a>
   </div>          

      `
       for(let i= 0;i<res.data.length;i++){
            if( i === 0){
                str +=`
                <div class="content-bd">
                <a href="./list.html" class="content-bd-l">
                <img  alt="" src='${res.data[i].verticalPic}' class="content-bd-l_pic">
                  <div class="bd-l">
                      <div class="bd-l-tit">${res.data[i].name}</div>
                      <div class="bd-l-cn">
                      ￥${res.data[i].formattedPriceStr.substr(0,3)}<span>起</span>
                          
                      </div>
                  </div>
              </a> 
              <div class="bd-r">
                `
                continue
            }
            str +=`
            <a href="./list.html" class="bd-r-item clearfixer">
            <div class="itemimg">
                <img  alt="" src='${res.data[i].verticalPic}'>
            </div>
            <div class="iteminfo">
                <div class="itemtit">
                ${res.data[i].name}
                </div>
                <div class="itemloc">
                ${res.data[i].venueName}</div>
                <div class="itemtime">
                ${res.data[i].showTime}
                </div>
                <div class="itempice">
               ￥${res.data[i].formattedPriceStr.substr(0,3)}<span>起</span>
               
                </div>
            </div>
          </a>    
            `
       }
       str +=`
       </div>
       </div>
    
       `
     $('.content1').html(str)
}

function jsonp144(res){
    var str = ``
     str += ` 
  
   <div class="content-head contet-head${arr[3].id}">
       <span class="content-head-tit ">${arr[3].name}</span>
       <a href="./list.html">
           <span class="content-more">查看全部</span>
       </a>
   </div>          

      `
       for(let i= 0;i<res.data.length;i++){
            if( i === 0){
                str +=`
                <div class="content-bd">
                <a href="./list.html" class="content-bd-l">
                <img  alt="" src='${res.data[i].verticalPic}' class="content-bd-l_pic">
                  <div class="bd-l">
                      <div class="bd-l-tit">${res.data[i].name}</div>
                      <div class="bd-l-cn">
                      ￥${res.data[i].formattedPriceStr.substr(0,3)}<span>起</span>
                          
                      </div>
                  </div>
              </a> 
              <div class="bd-r">
                `
                continue
            }
            str +=`
            <a href="./list.html" class="bd-r-item clearfixer">
            <div class="itemimg">
                <img  alt="" src='${res.data[i].verticalPic}'>
            </div>
            <div class="iteminfo">
                <div class="itemtit">
                ${res.data[i].name}
                </div>
                <div class="itemloc">
                ${res.data[i].venueName}</div>
                <div class="itemtime">
                ${res.data[i].showTime}
                </div>
                <div class="itempice">
               ￥${res.data[i].formattedPriceStr.substr(0,3)}<span>起</span>
               
                </div>
            </div>
          </a>    
            `
       }
       str +=`
       </div>
       </div>
     
       `
     $('.content4').html(str)
}
function jsonp130(res){
    var str = ``
     str += ` 
  
   <div class="content-head contet-head${arr[2].id}">
       <span class="content-head-tit ">${arr[2].name}</span>
       <a href="./list.html">
           <span class="content-more">查看全部</span>
       </a>
   </div>          

      `
       for(let i= 0;i<res.data.length;i++){
            if( i === 0){
                str +=`
                <div class="content-bd">
                <a href="./list.html" class="content-bd-l">
                <img  alt="" src='${res.data[i].verticalPic}' class="content-bd-l_pic">
                  <div class="bd-l">
                      <div class="bd-l-tit">${res.data[i].name}</div>
                      <div class="bd-l-cn">
                      ￥${res.data[i].formattedPriceStr.substr(0,3)}<span>起</span>
                          
                      </div>
                  </div>
              </a> 
              <div class="bd-r">
                `
                continue
            }
            str +=`
            <a href="" class="bd-r-item clearfixer">
            <div class="itemimg">
                <img  alt="" src='${res.data[i].verticalPic}'>
            </div>
            <div class="iteminfo">
                <div class="itemtit">
                ${res.data[i].name}
                </div>
                <div class="itemloc">
                ${res.data[i].venueName}</div>
                <div class="itemtime">
                ${res.data[i].showTime}
                </div>
                <div class="itempice">
               ￥${res.data[i].formattedPriceStr.substr(0,3)}<span>起</span>
               
                </div>
            </div>
          </a>    
            `
       }
       str +=`
       </div>
       </div>
     
       `
     $('.content3').html(str)
}
function jsonp116(res){
    var str = ``
     str += ` 
  
   <div class="content-head contet-head${arr[1].id}">
       <span class="content-head-tit ">${arr[1].name}</span>
       <a href="">
           <span class="content-more">查看全部</span>
       </a>
   </div>          

      `
       for(let i= 0;i<res.data.length;i++){
            if( i === 0){
                str +=`
                <div class="content-bd">
                <a href="" class="content-bd-l">
                <img  alt="" src='${res.data[i].verticalPic}' class="content-bd-l_pic">
                  <div class="bd-l">
                      <div class="bd-l-tit">${res.data[i].name}</div>
                      <div class="bd-l-cn">
                      ￥${res.data[i].formattedPriceStr.substr(0,3)}<span>起</span>
                          
                      </div>
                  </div>
              </a> 
              <div class="bd-r">
                `
                continue
            }
            str +=`
            <a href="" class="bd-r-item clearfixer">
            <div class="itemimg">
                <img  alt="" src='${res.data[i].verticalPic}'>
            </div>
            <div class="iteminfo">
                <div class="itemtit">
                ${res.data[i].name}
                </div>
                <div class="itemloc">
                ${res.data[i].venueName}</div>
                <div class="itemtime">
                ${res.data[i].showTime}
                </div>
                <div class="itempice">
               ￥${res.data[i].formattedPriceStr.substr(0,3)}<span>起</span>
               
                </div>
            </div>
          </a>    
            `
       }
       str +=`
       </div>
       </div>
     
       `
     $('.content2').html(str)
}
// 点击回到顶部
$(window).scroll(function(){
    // console.log()
    if($(window).scrollTop() >=240){
         $('.rtop').show()
    }else{
        $('.rtop').hide()
    }
})
$('.rtop').click(function(){
    // $(window).scrollTop()
  $('html').animate({
      scrollTop:0
  },300)
})


